using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.Core.DAL.SubSonicDAL
{
	/// <summary>
	/// Strongly-typed collection for the MedianamikControl class.
	/// </summary>
    [Serializable]
	public partial class MedianamikControlCollection : ActiveList<MedianamikControl, MedianamikControlCollection>
	{	   
		public MedianamikControlCollection() {}
        
        /// <summary>
		/// Filters an existing collection based on the set criteria. This is an in-memory filter
		/// Thanks to developingchris for this!
        /// </summary>
        /// <returns>MedianamikControlCollection</returns>
		public MedianamikControlCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                MedianamikControl o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
		
		
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the medianamik_MedianamikControl table.
	/// </summary>
	[Serializable]
	public partial class MedianamikControl : ActiveRecord<MedianamikControl>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public MedianamikControl()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public MedianamikControl(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public MedianamikControl(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public MedianamikControl(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("medianamik_MedianamikControl", TableType.Table, DataService.GetInstance("MedianamikProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarMedianamikControlID = new TableSchema.TableColumn(schema);
				colvarMedianamikControlID.ColumnName = "MedianamikControlID";
				colvarMedianamikControlID.DataType = DbType.Guid;
				colvarMedianamikControlID.MaxLength = 0;
				colvarMedianamikControlID.AutoIncrement = false;
				colvarMedianamikControlID.IsNullable = false;
				colvarMedianamikControlID.IsPrimaryKey = true;
				colvarMedianamikControlID.IsForeignKey = false;
				colvarMedianamikControlID.IsReadOnly = false;
				colvarMedianamikControlID.DefaultSetting = @"";
				colvarMedianamikControlID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMedianamikControlID);
				
				TableSchema.TableColumn colvarName = new TableSchema.TableColumn(schema);
				colvarName.ColumnName = "Name";
				colvarName.DataType = DbType.String;
				colvarName.MaxLength = 255;
				colvarName.AutoIncrement = false;
				colvarName.IsNullable = false;
				colvarName.IsPrimaryKey = false;
				colvarName.IsForeignKey = false;
				colvarName.IsReadOnly = false;
				colvarName.DefaultSetting = @"";
				colvarName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarName);
				
				TableSchema.TableColumn colvarMaySpecifyWidth = new TableSchema.TableColumn(schema);
				colvarMaySpecifyWidth.ColumnName = "MaySpecifyWidth";
				colvarMaySpecifyWidth.DataType = DbType.Boolean;
				colvarMaySpecifyWidth.MaxLength = 0;
				colvarMaySpecifyWidth.AutoIncrement = false;
				colvarMaySpecifyWidth.IsNullable = false;
				colvarMaySpecifyWidth.IsPrimaryKey = false;
				colvarMaySpecifyWidth.IsForeignKey = false;
				colvarMaySpecifyWidth.IsReadOnly = false;
				colvarMaySpecifyWidth.DefaultSetting = @"";
				colvarMaySpecifyWidth.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMaySpecifyWidth);
				
				TableSchema.TableColumn colvarDefaultWidth = new TableSchema.TableColumn(schema);
				colvarDefaultWidth.ColumnName = "DefaultWidth";
				colvarDefaultWidth.DataType = DbType.AnsiString;
				colvarDefaultWidth.MaxLength = 10;
				colvarDefaultWidth.AutoIncrement = false;
				colvarDefaultWidth.IsNullable = true;
				colvarDefaultWidth.IsPrimaryKey = false;
				colvarDefaultWidth.IsForeignKey = false;
				colvarDefaultWidth.IsReadOnly = false;
				colvarDefaultWidth.DefaultSetting = @"";
				colvarDefaultWidth.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDefaultWidth);
				
				TableSchema.TableColumn colvarMaySpecifyHeight = new TableSchema.TableColumn(schema);
				colvarMaySpecifyHeight.ColumnName = "MaySpecifyHeight";
				colvarMaySpecifyHeight.DataType = DbType.Boolean;
				colvarMaySpecifyHeight.MaxLength = 0;
				colvarMaySpecifyHeight.AutoIncrement = false;
				colvarMaySpecifyHeight.IsNullable = false;
				colvarMaySpecifyHeight.IsPrimaryKey = false;
				colvarMaySpecifyHeight.IsForeignKey = false;
				colvarMaySpecifyHeight.IsReadOnly = false;
				colvarMaySpecifyHeight.DefaultSetting = @"";
				colvarMaySpecifyHeight.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMaySpecifyHeight);
				
				TableSchema.TableColumn colvarDefaultHeight = new TableSchema.TableColumn(schema);
				colvarDefaultHeight.ColumnName = "DefaultHeight";
				colvarDefaultHeight.DataType = DbType.Int16;
				colvarDefaultHeight.MaxLength = 0;
				colvarDefaultHeight.AutoIncrement = false;
				colvarDefaultHeight.IsNullable = true;
				colvarDefaultHeight.IsPrimaryKey = false;
				colvarDefaultHeight.IsForeignKey = false;
				colvarDefaultHeight.IsReadOnly = false;
				colvarDefaultHeight.DefaultSetting = @"";
				colvarDefaultHeight.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDefaultHeight);
				
				TableSchema.TableColumn colvarMaySpecifyLength = new TableSchema.TableColumn(schema);
				colvarMaySpecifyLength.ColumnName = "MaySpecifyLength";
				colvarMaySpecifyLength.DataType = DbType.Boolean;
				colvarMaySpecifyLength.MaxLength = 0;
				colvarMaySpecifyLength.AutoIncrement = false;
				colvarMaySpecifyLength.IsNullable = false;
				colvarMaySpecifyLength.IsPrimaryKey = false;
				colvarMaySpecifyLength.IsForeignKey = false;
				colvarMaySpecifyLength.IsReadOnly = false;
				colvarMaySpecifyLength.DefaultSetting = @"";
				colvarMaySpecifyLength.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMaySpecifyLength);
				
				TableSchema.TableColumn colvarDefaultLength = new TableSchema.TableColumn(schema);
				colvarDefaultLength.ColumnName = "DefaultLength";
				colvarDefaultLength.DataType = DbType.Int16;
				colvarDefaultLength.MaxLength = 0;
				colvarDefaultLength.AutoIncrement = false;
				colvarDefaultLength.IsNullable = true;
				colvarDefaultLength.IsPrimaryKey = false;
				colvarDefaultLength.IsForeignKey = false;
				colvarDefaultLength.IsReadOnly = false;
				colvarDefaultLength.DefaultSetting = @"";
				colvarDefaultLength.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDefaultLength);
				
				TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
				colvarCreatedOn.ColumnName = "CreatedOn";
				colvarCreatedOn.DataType = DbType.DateTime;
				colvarCreatedOn.MaxLength = 0;
				colvarCreatedOn.AutoIncrement = false;
				colvarCreatedOn.IsNullable = false;
				colvarCreatedOn.IsPrimaryKey = false;
				colvarCreatedOn.IsForeignKey = false;
				colvarCreatedOn.IsReadOnly = false;
				colvarCreatedOn.DefaultSetting = @"";
				colvarCreatedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedOn);
				
				TableSchema.TableColumn colvarType = new TableSchema.TableColumn(schema);
				colvarType.ColumnName = "Type";
				colvarType.DataType = DbType.Byte;
				colvarType.MaxLength = 0;
				colvarType.AutoIncrement = false;
				colvarType.IsNullable = false;
				colvarType.IsPrimaryKey = false;
				colvarType.IsForeignKey = false;
				colvarType.IsReadOnly = false;
				colvarType.DefaultSetting = @"";
				colvarType.ForeignKeyTableName = "";
				schema.Columns.Add(colvarType);
				
				TableSchema.TableColumn colvarFullName = new TableSchema.TableColumn(schema);
				colvarFullName.ColumnName = "FullName";
				colvarFullName.DataType = DbType.String;
				colvarFullName.MaxLength = 255;
				colvarFullName.AutoIncrement = false;
				colvarFullName.IsNullable = true;
				colvarFullName.IsPrimaryKey = false;
				colvarFullName.IsForeignKey = false;
				colvarFullName.IsReadOnly = false;
				colvarFullName.DefaultSetting = @"";
				colvarFullName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFullName);
				
				TableSchema.TableColumn colvarMaySpecifyValidationExpression = new TableSchema.TableColumn(schema);
				colvarMaySpecifyValidationExpression.ColumnName = "MaySpecifyValidationExpression";
				colvarMaySpecifyValidationExpression.DataType = DbType.Boolean;
				colvarMaySpecifyValidationExpression.MaxLength = 0;
				colvarMaySpecifyValidationExpression.AutoIncrement = false;
				colvarMaySpecifyValidationExpression.IsNullable = false;
				colvarMaySpecifyValidationExpression.IsPrimaryKey = false;
				colvarMaySpecifyValidationExpression.IsForeignKey = false;
				colvarMaySpecifyValidationExpression.IsReadOnly = false;
				colvarMaySpecifyValidationExpression.DefaultSetting = @"";
				colvarMaySpecifyValidationExpression.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMaySpecifyValidationExpression);
				
				TableSchema.TableColumn colvarMayBeRequired = new TableSchema.TableColumn(schema);
				colvarMayBeRequired.ColumnName = "MayBeRequired";
				colvarMayBeRequired.DataType = DbType.Boolean;
				colvarMayBeRequired.MaxLength = 0;
				colvarMayBeRequired.AutoIncrement = false;
				colvarMayBeRequired.IsNullable = false;
				colvarMayBeRequired.IsPrimaryKey = false;
				colvarMayBeRequired.IsForeignKey = false;
				colvarMayBeRequired.IsReadOnly = false;
				colvarMayBeRequired.DefaultSetting = @"";
				colvarMayBeRequired.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMayBeRequired);
				
				TableSchema.TableColumn colvarMayBeUnique = new TableSchema.TableColumn(schema);
				colvarMayBeUnique.ColumnName = "MayBeUnique";
				colvarMayBeUnique.DataType = DbType.Boolean;
				colvarMayBeUnique.MaxLength = 0;
				colvarMayBeUnique.AutoIncrement = false;
				colvarMayBeUnique.IsNullable = false;
				colvarMayBeUnique.IsPrimaryKey = false;
				colvarMayBeUnique.IsForeignKey = false;
				colvarMayBeUnique.IsReadOnly = false;
				colvarMayBeUnique.DefaultSetting = @"";
				colvarMayBeUnique.ForeignKeyTableName = "";
				schema.Columns.Add(colvarMayBeUnique);
				
				TableSchema.TableColumn colvarDataTypeID = new TableSchema.TableColumn(schema);
				colvarDataTypeID.ColumnName = "DataTypeID";
				colvarDataTypeID.DataType = DbType.Guid;
				colvarDataTypeID.MaxLength = 0;
				colvarDataTypeID.AutoIncrement = false;
				colvarDataTypeID.IsNullable = false;
				colvarDataTypeID.IsPrimaryKey = false;
				colvarDataTypeID.IsForeignKey = false;
				colvarDataTypeID.IsReadOnly = false;
				colvarDataTypeID.DefaultSetting = @"";
				colvarDataTypeID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDataTypeID);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["MedianamikProvider"].AddSchema("medianamik_MedianamikControl",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("MedianamikControlID")]
		[Bindable(true)]
		public Guid MedianamikControlID 
		{
			get { return GetColumnValue<Guid>(Columns.MedianamikControlID); }
			set { SetColumnValue(Columns.MedianamikControlID, value); }
		}
		  
		[XmlAttribute("Name")]
		[Bindable(true)]
		public string Name 
		{
			get { return GetColumnValue<string>(Columns.Name); }
			set { SetColumnValue(Columns.Name, value); }
		}
		  
		[XmlAttribute("MaySpecifyWidth")]
		[Bindable(true)]
		public bool MaySpecifyWidth 
		{
			get { return GetColumnValue<bool>(Columns.MaySpecifyWidth); }
			set { SetColumnValue(Columns.MaySpecifyWidth, value); }
		}
		  
		[XmlAttribute("DefaultWidth")]
		[Bindable(true)]
		public string DefaultWidth 
		{
			get { return GetColumnValue<string>(Columns.DefaultWidth); }
			set { SetColumnValue(Columns.DefaultWidth, value); }
		}
		  
		[XmlAttribute("MaySpecifyHeight")]
		[Bindable(true)]
		public bool MaySpecifyHeight 
		{
			get { return GetColumnValue<bool>(Columns.MaySpecifyHeight); }
			set { SetColumnValue(Columns.MaySpecifyHeight, value); }
		}
		  
		[XmlAttribute("DefaultHeight")]
		[Bindable(true)]
		public short? DefaultHeight 
		{
			get { return GetColumnValue<short?>(Columns.DefaultHeight); }
			set { SetColumnValue(Columns.DefaultHeight, value); }
		}
		  
		[XmlAttribute("MaySpecifyLength")]
		[Bindable(true)]
		public bool MaySpecifyLength 
		{
			get { return GetColumnValue<bool>(Columns.MaySpecifyLength); }
			set { SetColumnValue(Columns.MaySpecifyLength, value); }
		}
		  
		[XmlAttribute("DefaultLength")]
		[Bindable(true)]
		public short? DefaultLength 
		{
			get { return GetColumnValue<short?>(Columns.DefaultLength); }
			set { SetColumnValue(Columns.DefaultLength, value); }
		}
		  
		[XmlAttribute("CreatedOn")]
		[Bindable(true)]
		public DateTime CreatedOn 
		{
			get { return GetColumnValue<DateTime>(Columns.CreatedOn); }
			set { SetColumnValue(Columns.CreatedOn, value); }
		}
		  
		[XmlAttribute("Type")]
		[Bindable(true)]
		public byte Type 
		{
			get { return GetColumnValue<byte>(Columns.Type); }
			set { SetColumnValue(Columns.Type, value); }
		}
		  
		[XmlAttribute("FullName")]
		[Bindable(true)]
		public string FullName 
		{
			get { return GetColumnValue<string>(Columns.FullName); }
			set { SetColumnValue(Columns.FullName, value); }
		}
		  
		[XmlAttribute("MaySpecifyValidationExpression")]
		[Bindable(true)]
		public bool MaySpecifyValidationExpression 
		{
			get { return GetColumnValue<bool>(Columns.MaySpecifyValidationExpression); }
			set { SetColumnValue(Columns.MaySpecifyValidationExpression, value); }
		}
		  
		[XmlAttribute("MayBeRequired")]
		[Bindable(true)]
		public bool MayBeRequired 
		{
			get { return GetColumnValue<bool>(Columns.MayBeRequired); }
			set { SetColumnValue(Columns.MayBeRequired, value); }
		}
		  
		[XmlAttribute("MayBeUnique")]
		[Bindable(true)]
		public bool MayBeUnique 
		{
			get { return GetColumnValue<bool>(Columns.MayBeUnique); }
			set { SetColumnValue(Columns.MayBeUnique, value); }
		}
		  
		[XmlAttribute("DataTypeID")]
		[Bindable(true)]
		public Guid DataTypeID 
		{
			get { return GetColumnValue<Guid>(Columns.DataTypeID); }
			set { SetColumnValue(Columns.DataTypeID, value); }
		}
		
		#endregion
		
		
		#region PrimaryKey Methods		
		
        protected override void SetPrimaryKey(object oValue)
        {
            base.SetPrimaryKey(oValue);
            
            SetPKValues();
        }
        
		
		private Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection colPropertyXRecords;
		public Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection PropertyXRecords()
		{
			if(colPropertyXRecords == null)
			{
				colPropertyXRecords = new Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection().Where(PropertyX.Columns.PrimaryMedianamikControlId, MedianamikControlID).Load();
				colPropertyXRecords.ListChanged += new ListChangedEventHandler(colPropertyXRecords_ListChanged);
			}
			return colPropertyXRecords;
		}
				
		void colPropertyXRecords_ListChanged(object sender, ListChangedEventArgs e)
		{
            if (e.ListChangedType == ListChangedType.ItemAdded)
            {
		        // Set foreign key value
		        colPropertyXRecords[e.NewIndex].PrimaryMedianamikControlId = MedianamikControlID;
				colPropertyXRecords.ListChanged += new ListChangedEventHandler(colPropertyXRecords_ListChanged);
            }
		}
		private Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection colPropertyXRecordsFromMedianamikControl;
		public Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection PropertyXRecordsFromMedianamikControl()
		{
			if(colPropertyXRecordsFromMedianamikControl == null)
			{
				colPropertyXRecordsFromMedianamikControl = new Medianamik.Core.DAL.SubSonicDAL.PropertyXCollection().Where(PropertyX.Columns.MedianamikControlId, MedianamikControlID).Load();
				colPropertyXRecordsFromMedianamikControl.ListChanged += new ListChangedEventHandler(colPropertyXRecordsFromMedianamikControl_ListChanged);
			}
			return colPropertyXRecordsFromMedianamikControl;
		}
				
		void colPropertyXRecordsFromMedianamikControl_ListChanged(object sender, ListChangedEventArgs e)
		{
            if (e.ListChangedType == ListChangedType.ItemAdded)
            {
		        // Set foreign key value
		        colPropertyXRecordsFromMedianamikControl[e.NewIndex].MedianamikControlId = MedianamikControlID;
				colPropertyXRecordsFromMedianamikControl.ListChanged += new ListChangedEventHandler(colPropertyXRecordsFromMedianamikControl_ListChanged);
            }
		}
		#endregion
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(Guid varMedianamikControlID,string varName,bool varMaySpecifyWidth,string varDefaultWidth,bool varMaySpecifyHeight,short? varDefaultHeight,bool varMaySpecifyLength,short? varDefaultLength,DateTime varCreatedOn,byte varType,string varFullName,bool varMaySpecifyValidationExpression,bool varMayBeRequired,bool varMayBeUnique,Guid varDataTypeID)
		{
			MedianamikControl item = new MedianamikControl();
			
			item.MedianamikControlID = varMedianamikControlID;
			
			item.Name = varName;
			
			item.MaySpecifyWidth = varMaySpecifyWidth;
			
			item.DefaultWidth = varDefaultWidth;
			
			item.MaySpecifyHeight = varMaySpecifyHeight;
			
			item.DefaultHeight = varDefaultHeight;
			
			item.MaySpecifyLength = varMaySpecifyLength;
			
			item.DefaultLength = varDefaultLength;
			
			item.CreatedOn = varCreatedOn;
			
			item.Type = varType;
			
			item.FullName = varFullName;
			
			item.MaySpecifyValidationExpression = varMaySpecifyValidationExpression;
			
			item.MayBeRequired = varMayBeRequired;
			
			item.MayBeUnique = varMayBeUnique;
			
			item.DataTypeID = varDataTypeID;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(Guid varMedianamikControlID,string varName,bool varMaySpecifyWidth,string varDefaultWidth,bool varMaySpecifyHeight,short? varDefaultHeight,bool varMaySpecifyLength,short? varDefaultLength,DateTime varCreatedOn,byte varType,string varFullName,bool varMaySpecifyValidationExpression,bool varMayBeRequired,bool varMayBeUnique,Guid varDataTypeID)
		{
			MedianamikControl item = new MedianamikControl();
			
				item.MedianamikControlID = varMedianamikControlID;
			
				item.Name = varName;
			
				item.MaySpecifyWidth = varMaySpecifyWidth;
			
				item.DefaultWidth = varDefaultWidth;
			
				item.MaySpecifyHeight = varMaySpecifyHeight;
			
				item.DefaultHeight = varDefaultHeight;
			
				item.MaySpecifyLength = varMaySpecifyLength;
			
				item.DefaultLength = varDefaultLength;
			
				item.CreatedOn = varCreatedOn;
			
				item.Type = varType;
			
				item.FullName = varFullName;
			
				item.MaySpecifyValidationExpression = varMaySpecifyValidationExpression;
			
				item.MayBeRequired = varMayBeRequired;
			
				item.MayBeUnique = varMayBeUnique;
			
				item.DataTypeID = varDataTypeID;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn MedianamikControlIDColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn NameColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn MaySpecifyWidthColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn DefaultWidthColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        public static TableSchema.TableColumn MaySpecifyHeightColumn
        {
            get { return Schema.Columns[4]; }
        }
        
        
        
        public static TableSchema.TableColumn DefaultHeightColumn
        {
            get { return Schema.Columns[5]; }
        }
        
        
        
        public static TableSchema.TableColumn MaySpecifyLengthColumn
        {
            get { return Schema.Columns[6]; }
        }
        
        
        
        public static TableSchema.TableColumn DefaultLengthColumn
        {
            get { return Schema.Columns[7]; }
        }
        
        
        
        public static TableSchema.TableColumn CreatedOnColumn
        {
            get { return Schema.Columns[8]; }
        }
        
        
        
        public static TableSchema.TableColumn TypeColumn
        {
            get { return Schema.Columns[9]; }
        }
        
        
        
        public static TableSchema.TableColumn FullNameColumn
        {
            get { return Schema.Columns[10]; }
        }
        
        
        
        public static TableSchema.TableColumn MaySpecifyValidationExpressionColumn
        {
            get { return Schema.Columns[11]; }
        }
        
        
        
        public static TableSchema.TableColumn MayBeRequiredColumn
        {
            get { return Schema.Columns[12]; }
        }
        
        
        
        public static TableSchema.TableColumn MayBeUniqueColumn
        {
            get { return Schema.Columns[13]; }
        }
        
        
        
        public static TableSchema.TableColumn DataTypeIDColumn
        {
            get { return Schema.Columns[14]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string MedianamikControlID = @"MedianamikControlID";
			 public static string Name = @"Name";
			 public static string MaySpecifyWidth = @"MaySpecifyWidth";
			 public static string DefaultWidth = @"DefaultWidth";
			 public static string MaySpecifyHeight = @"MaySpecifyHeight";
			 public static string DefaultHeight = @"DefaultHeight";
			 public static string MaySpecifyLength = @"MaySpecifyLength";
			 public static string DefaultLength = @"DefaultLength";
			 public static string CreatedOn = @"CreatedOn";
			 public static string Type = @"Type";
			 public static string FullName = @"FullName";
			 public static string MaySpecifyValidationExpression = @"MaySpecifyValidationExpression";
			 public static string MayBeRequired = @"MayBeRequired";
			 public static string MayBeUnique = @"MayBeUnique";
			 public static string DataTypeID = @"DataTypeID";
						
		}
		#endregion
		
		#region Update PK Collections
		
        public void SetPKValues()
        {
                if (colPropertyXRecords != null)
                {
                    foreach (Medianamik.Core.DAL.SubSonicDAL.PropertyX item in colPropertyXRecords)
                    {
                        if (item.PrimaryMedianamikControlId != MedianamikControlID)
                        {
                            item.PrimaryMedianamikControlId = MedianamikControlID;
                        }
                    }
               }
		
                if (colPropertyXRecordsFromMedianamikControl != null)
                {
                    foreach (Medianamik.Core.DAL.SubSonicDAL.PropertyX item in colPropertyXRecordsFromMedianamikControl)
                    {
                        if (item.MedianamikControlId != MedianamikControlID)
                        {
                            item.MedianamikControlId = MedianamikControlID;
                        }
                    }
               }
		}
        #endregion
    
        #region Deep Save
		
        public void DeepSave()
        {
            Save();
            
                if (colPropertyXRecords != null)
                {
                    colPropertyXRecords.SaveAll();
               }
		
                if (colPropertyXRecordsFromMedianamikControl != null)
                {
                    colPropertyXRecordsFromMedianamikControl.SaveAll();
               }
		}
        #endregion
	}
}
